// 懒加载路由
const Index = r => require.ensure([], () => r(require("@/views/index/index")), "basic")
const Form = r => require.ensure([], () => r(require("@/views/form/index")), "basic")
const Calendar = r => require.ensure([], () => r(require("@/views/calendar/index")), "basic")
const Icon = r => require.ensure([], () => r(require("@/views/icon/index")), "basic")
const QuillEditor = r => require.ensure([], () => r(require("@/views/editor/quill")), "basic")
const WangEditor = r => require.ensure([], () => r(require("@/views/editor/wang")), "basic")
const Markdown = r => require.ensure([], () => r(require("@/views/markdown/index")), "basic")
const BarChart = r => require.ensure([], () => r(require("@/views/chart/barchart")), "basic")
const PieChart = r => require.ensure([], () => r(require("@/views/chart/piechart")), "basic")
const Verify = r => require.ensure([], () => r(require("@/views/verify/index")), "basic")
const Video = r => require.ensure([], () => r(require("@/views/video/index")), "basic")
const Guide = r => require.ensure([], () => r(require("@/views/guide/index")), "basic")
const Clipboard = r => require.ensure([], () => r(require("@/views/clipboard/index")), "basic")
const Xss = r => require.ensure([], () => r(require("@/views/plugin/xss")), "basic")
const Permission_Page = r => require.ensure([], () => r(require("@/views/permission/page")), "basic")
const Permission_Button = r => require.ensure([], () => r(require("@/views/permission/button")), "basic")
const NotPerPage = r => require.ensure([], () => r(require("@/views/401")), "basic")
const ErrorPage = r => require.ensure([], () => r(require("@/views/404")), "basic")

// 必须引入该组件以支持二级子路由显示
const children = {template: '<router-view></router-view>'}

export default [
	{
		path: '/index',
		name: 'Index',
		component: Index,
		meta: {
			title: '主页',
			keepAlive: false, //是否需要缓存组件
			icon: 'el-icon-house',
			showToMenu: true, //是否展示在菜单上
			isTopMenu: true //是否顶级菜单
		}
	},
	{
		path: '/form',
		name: 'Form',
		component: Form,
		meta: {
			title: '表单验证',
			keepAlive: false,
			icon: 'el-icon-document',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/calendar',
		name: 'Calendar',
		component: Calendar,
		meta: {
			title: '农历日历',
			keepAlive: false,
			icon: 'el-icon-date',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/icon',
		name: 'Icon',
		component: Icon,
		meta: {
			title: '自定义图标',
			keepAlive: false,
			icon: 'el-icon-collection-tag',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/editor',
		name: 'Editor',
		component: children,
		meta: {
			title: '富文本',
			icon: 'el-icon-edit',
			showToMenu: true,
			isTopMenu: false
		},
		children: [
			{
				path: '/editor/quilleditor',
				name: 'QuillEditor',
				component: QuillEditor,
				meta: {
					title: 'QuillEditor',
					keepAlive: false,
					icon: 'el-icon-edit-outline'
				}
			},
			{
				path: '/editor/wangeditor',
				name: 'WangEditor',
				component: WangEditor,
				meta: {
					title: 'WangEditor',
					keepAlive: false,
					icon: 'el-icon-edit-outline'
				}
			}
		]
	},
	{
		path: '/markdown',
		name: 'Markdown',
		component: Markdown,
		meta: {
			title: 'Markdown',
			keepAlive: false,
			icon: 'el-icon-edit-outline',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/chart',
		name: 'Chart',
		component: children,
		meta: {
			title: 'Echart图表',
			icon: 'el-icon-data-line',
			showToMenu: true,
			isTopMenu: false
		},
		children: [
			{
				path: '/chart/barchart',
				name: 'BarChart',
				component: BarChart,
				meta: {
					title: '柱形图',
					keepAlive: false,
					icon: 'el-icon-data-analysis'
				}
			},
			{
				path: '/chart/piechart',
				name: 'PieChart',
				component: PieChart,
				meta: {
					title: '饼图',
					keepAlive: false,
					icon: 'el-icon-pie-chart'
				}
			}
		]
	},
	{
		path: '/verify',
		name: 'Verify',
		component: Verify,
		meta: {
			title: '滑动验证',
			keepAlive: false,
			icon: 'el-icon-open',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/video',
		name: 'Video',
		component: Video,
		meta: {
			title: '视频播放器',
			keepAlive: false,
			icon: 'el-icon-video-camera',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/guide',
		name: 'Guide',
		component: Guide,
		meta: {
			title: '引导提示',
			keepAlive: false,
			icon: 'el-icon-thumb',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/clipboard',
		name: 'Clipboard',
		component: Clipboard,
		meta: {
			title: 'Clipboard',
			keepAlive: false,
			icon: 'el-icon-document-copy',
			showToMenu: true,
			isTopMenu: true
		}
	},
	{
		path: '/plugin',
		name: 'Plugin',
		component: children,
		meta: {
			title: '其他插件',
			icon: 'el-icon-setting',
			showToMenu: true,
			isTopMenu: false
		},
		children: [
			{
				path: '/plugin/xss',
				name: 'Xss',
				component: Xss,
				meta: {
					title: 'Vue XSS',
					keepAlive: false,
					icon: 'el-icon-link'
				}
			}
		]
	},
	{
		path: '/permission',
		name: 'Permission',
		component: children,
		meta: {
			title: '权限测试',
			icon: 'el-icon-lock',
			showToMenu: true,
			isTopMenu: false
		},
		children: [
			{
				path: '/permission/page',
				name: 'Permission_Page',
				component: Permission_Page,
				meta: {
					title: '页面权限',
					keepAlive: false,
					icon: 'el-icon-document',
					requiresAuth: true,
					roles: ['admin']
				}
			},
			{	
				path: '/permission/button',
				name: 'Permission_Button',
				component: Permission_Button,
				meta: {
					title: '按钮权限',
					keepAlive: false,
					icon: 'el-icon-mouse',
					requiresAuth: true,
					roles: ['admin','editor']
				}
			}
		]
	},
	{
		path: '/error',
		name: 'Error',
		component: children,
		meta: {
			title: '错误页面',
			icon: 'el-icon-warning-outline',
			showToMenu: true,
			isTopMenu: false
		},
		children: [
			{
				path: '/401',
				name: 'NotPerPage',
				component: NotPerPage,
				meta: {
					title: '401错误页面',
					keepAlive: false,
					icon: 'el-icon-circle-close',
				}
			},
			{
				path: '/404',
				name: 'ErrorPage',
				component: ErrorPage,
				meta: {
					title: '404错误页面',
					keepAlive: false,
					icon: 'el-icon-circle-close',
				}
			}
		]
	}
]

